(function (){

	remComputer ()
	window.onresize = function () {

		console.log("bianhuale")
		remComputer ()
	}
	function remComputer(){
		var w = document.documentElement.clientWidth || document.body.clientWidth
		var doc = document.getElementsByTagName("html")[0]
		if (w > 750) {
			doc.style.fontSize = 100 + 'px'
		} else {
			doc.style.fontSize = w / 7.5 + 'px'
		}
	}
})()
//获取当天的时间
function getMonthFirstDay(isHours) {
	var nowDate = new Date();
	var year = nowDate.getFullYear();
	var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
	var day = nowDate.getDate();
	var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
	if (day < 25) {
		var mon = nowDate.getMonth() + 1;
		if (mon == 1)
			month = 12;
		else
			month = (mon - 1) < 10 ? "0" + (mon - 1) : mon - 1;
		date = 25;
	}
	if (isHours)
		return year + "-" + month + "-" + date + " 08:30:00";
	else
		return year + "-" + month + "-" + date;

}
function differenceMin(time1, time2) {
	var date1 = new Date(time1);
	var date2 = new Date(time2);

	var sec = date1.getTime() - date2.getTime();
	var min = Math.round(sec / 1000 / 60);
	return min;
}

//获取当天的时间
function getNowTime() {
	var nowDate = new Date();
	var year = nowDate.getFullYear();
	var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
	var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
	return year + "-" + month + "-" + date + " 08:30:00";
}
function getNowTime(isHours) {
	var nowDate = new Date();
	var year = nowDate.getFullYear();
	var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
	var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
	if (isHours)
		return year + "-" + month + "-" + date + " 08:30:00";
	else
		return year + "-" + month + "-" + date;
}
//获取下一天的时间
function getNextTime() {
	var nowDate = new Date();
	var year = nowDate.getFullYear();
	var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
	var date = nowDate.getDate() + 1;
	date = date < 10 ? "0" + date : date;
	return year + "-" + month + "-" + date + " 00:00:00";
}
//获取几天前的日期
function getBeforeDay(day, isHours) {
	var date1 = new Date();
	var date2 = new Date(date1);
	date2.setDate(date1.getDate() - day);
	var year = date2.getFullYear();
	var month = date2.getMonth() + 1 < 10 ? "0" + (date2.getMonth() + 1) : date2.getMonth() + 1;
	var date = date2.getDate() + 1;
	date = date < 10 ? "0" + date : date;
	if (isHours)
		return year + "-" + month + "-" + date + " 00:00:00";
	else
		return year + "-" + month + "-" + date;
}
//获取几个月前的日期(格式yyyy-MM)
function getBeforeMonth(month) {
	var date1 = new Date();
	var date2 = new Date(date1);
	date2.setMonth(date1.getMonth() - month);
	var year = date2.getFullYear();
	var month = date2.getMonth() + 1 < 10 ? "0" + (date2.getMonth() + 1) : date2.getMonth() + 1;
	return year + "-" + month;
}

function ckBoxColor() {
	//复选框样式
	$("body").on("mouseenter", ".ckBox", function() {
		if($(this).hasClass("on")) {
			return;
		} else {
			$(this).addClass("hover");
		}
	})
	$("body").on("mouseout", ".ckBox", function() {
		$(this).removeClass("hover");
	})
	$("body").on("click", ".ckBox", function() {
		//如果是全选 
		if($(this).hasClass("allCKBox")) {
			$(this).toggleClass("on").removeClass("hover");
			if($(this).hasClass("on")) { //全选
				$(".tableList .ckBox").removeClass("hover").addClass("on");
			} else {
				$(".tableList .ckBox").removeClass("on");
			}
		} else {
			$(this).toggleClass("on").removeClass("hover");
		}
	})
}

function isNumber(value) { //验证是否为数字
	var patrn = /^\d+(\.\d+)?$/;
	return patrn.test(value);
}

//使用空字符串替换所有值为undefined的td
//ele 为表格的类名或id 或者父级对象
function replaceNull(ele) {
	var arrVal = $(ele).find("td");
	for(var i = 0; i < arrVal.length; i++) {
		if(arrVal[i].innerHTML == 'undefined') {
			arrVal[i].innerHTML = '';
		}
	}
}

/**显示值转换**/
function convertVal(val) {
	if (isNull(val))
		return '';
	else
		return val;
}

/**显示值转换**/
function convertNumber(val) {
	if (isNull(val))
		return 0;
	else
		return val;
}

function isNull(val) {
	if (val == null || val == undefined || val =='' || val == 'undefined' || val == 'null')
		return true;
	else
		return false;
}

function ckIsNull(ele) {
	var inputs = $(ele).find("input[lay-verify='required']");
	for(var i = 0; i < inputs.length; i++) {
		var str = $.trim(inputs[i].val());
		if(str == '' || str == null) {
			return 0;
		}
	}

}
